/**
 * 
 */
package com.sesame.daoimpl;

import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.sesame.dao.ComplaintDAO;
import com.sesame.domain.Complaint;

/**
 * @author shubeta
 *
 */
public class ComplaintDAOImpl extends SqlMapClientDaoSupport implements ComplaintDAO {

    public void addComplaint(Complaint complaint) {
        getSqlMapClientTemplate().insert("addComplaint", complaint);
    }

    public void deleteComplaintById(Integer id) {
        getSqlMapClientTemplate().delete("deleteComplaintById", id);
    }
    
    public void deleteComplaintByState(char state) {
        getSqlMapClientTemplate().delete("deleteComplaintByState", state);
    }
    
    @SuppressWarnings("unchecked")
    public List<Complaint> getAllComplaint() {
        return (List<Complaint>) getSqlMapClientTemplate().queryForList("getAllComplaint");
    }

    public Complaint getComplaintByNickName(String nickName) {
        return (Complaint) getSqlMapClientTemplate().queryForObject("getComplaintByNickName", nickName);
    }

    public void updateComplaint(Complaint complaint) {
        getSqlMapClientTemplate().update("updateComplaint", complaint);
    }

}
